//--------------------------------------------------- // Purpose: Demonstrate functions and parameters // Author: John Gauch //--------------------------------------------------- #include using namespace std; void swap1(int &A, int &B) { cout << A << " " << B << endl; int temp = A; A = B; B = temp; cout << A << " " << B << endl; } int compare1(int X, int Y, int Z) { cout << X << " " << Y << " " << Z << endl; if (X > Y) swap1(X, Y); if (X > Z) swap1(X, Z); cout << X << " " << Y << " " << Z << endl; return X; } void swap2(int &A, int &B) { cout << A << " " << B << endl; if (A > B) { int temp = A; A = B; B = temp; } cout << A << " " << B << endl; } int compare2(int X, int Y, int Z) { cout << X << " " << Y << " " << Z << endl; swap2(X, Y); swap2(Y, Z); cout << X << " " << Y << " " << Z << endl; return Z; } int main() { cout << "\nPart A\n"; int U = 5; int V = 3; swap1(U,V); cout << "\nPart B\n"; int Result1 = compare1(4, 9, 1); cout << "Result1: " << Result1 << endl; cout << "\nPart C\n"; U = 7; V = 1; swap2(U,V); cout << "\nPart D\n"; int Result2 = compare2(6, 8, 2); cout << "Result2: " << Result2 << endl; return 0; }